<template>
  <div class="home">
    <ul>
      <li v-for="(item, index) in arr" :key="index">
        订单日期 --- {{item.time | formateTime}}
        <br />
        订单日期 --- {{changeTime(item.time)}}
        <br />
        商品价格 --- {{item.price |　formatePrice}}
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  name: 'Home',
  data() {
    return {
      arr:[
        {
          name:'羽绒服',
          price: 300,
          time: '2021-11-13 12:12:12'
        },
        {
          name:'羽绒服',
          price: 300,
          time: '2021-11-13 12:12:12'
        },
        {
          name:'羽绒服',
          price: 300,
          time: '2021-11-13 12:12:12'
        }
      ]
    }
  },
  filters: {
    formateTime(val) {
      // console.log(val);
      let date = new Date(val)
      let year = date.getFullYear()
      let month = date.getMonth() + 1
      let day = date.getDate()
      return `${year}/${month}/${day}`
    },

    deepFilter(val) {
      console.log(val);
    }
  },

  methods: {
    changeTime(time) {
      let date = new Date(time)
      let year = date.getFullYear()
      let month = date.getMonth() + 1
      let day = date.getDate()
      return `${year}/${month}/${day}`
    }
  }
}
</script>
